#include<bits/stdc++.h>
#define XH(i,a,b) for(int i=a;i<b;++i)
#define XXH(i,a,b) for(int i=a-1;i>=b;--i)
#define LL long long
using namespace std;
int tmpINT; string tmpSTRING; char tmpCHAR; double tmpDOUBLE; LL tmpLONGLONG;

struct window
{
	int x1,y1,x2,y2;
	int index;
	window *next = NULL;
};

int main(){
	int n,m;scanf("%d%d", &n,&m);
	window windows[n];
	XH(i , 0 , n){
		int x1,y1,x2,y2;
		scanf("%d%d%d%d", &x1,&y1,&x2,&y2);
		windows[i].x1 = x1;windows[i].x2 = x2;windows[i].y1=y1;windows[i].y2=y2;		
		windows[i].index = i+1;
	}
	window *root = &windows[n-1];
	XXH(i , n , 1)windows[i].next = &windows[i-1];
	XH(i , 0 , m){
		int x,y;scanf("%d%d", &x,&y);
		window *p = root->next,*pre = root;
		if(x>=root->x1&&y>=root->y1&&x<=root->x2&&y<=root->y2){
			printf("%d\n", root->index);
			continue;
		}
		while(p!=NULL){
			// printf("p.x = %d, p.y = %d\n",p->x1,p->y1 );
			if(x>=p->x1&&y>=p->y1&&x<=p->x2&&y<=p->y2){
				printf("%d\n", p->index);
				pre->next = p->next;
				p->next = root;
				root = p;
				break;
			}
			pre = p;
			p = p->next;
		}
		if(p == NULL)printf("IGNORED\n");
	}

	return 0;
}